import { proxy } from "valtio";
import {get,post} from "../request"
interface DataType {
    key: string;
    date: string;
    shop: string;
    brand: string;
    platform: string;
    Totalorderquantity: number;
    Settledorders: number;
    Unsubscribeorder: number;
    businesssales: number;
    Paidinamount: number;
    Deliveryfee: number;
    Platformsubsidies: number;
    servicecharge: number;
}

export const Finance4 = proxy({
    data: [] as DataType[],
    brand:"",
    shop:"",
    partition:"",
    platform:"",
    date:"",
    today:"",
    getArgs:(brand:string,partition:string,shop:string,platform:string,date:string,today:string)=>{
        Finance4.brand = brand
        Finance4.partition = partition
        Finance4.shop = shop
        Finance4.platform = platform
        Finance4.date = date
        Finance4.today = today
    },
    getList: () => {
        get("/daily").then((res:any) => {
            Finance4.data = res.data as DataType[]
        })
    },
    search:()=>{
        post("/daily/search",{
            brand:Finance4.brand,
            partition:Finance4.partition,
            shop:Finance4.shop,
            platform:Finance4.platform,
            date:Finance4.date,
            today:Finance4.today
        }).then((res:any)=>{
            Finance4.data = res.data as DataType[]
        })
    }
})
